{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between mb-3">
    <h2>我的火车票</h2>
    <a href="{{ url_for('add_train_ticket') }}" class="btn btn-primary">添加火车票</a>
</div>

<table class="table table-striped">
    <thead>
        <tr>
            <th>车次</th>
            <th>出发站</th>
            <th>到达站</th>
            <th>出发时间</th>
            <th>票价</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {% for ticket in tickets %}
        <tr>
            <td>{{ ticket.train_number }}</td>
            <td>{{ ticket.departure_station }}</td>
            <td>{{ ticket.arrival_station }}</td>
            <td>{{ ticket.departure_date }} {{ ticket.departure_time }}</td>
            <td>¥{{ ticket.price }}</td>
            <td>
                <a href="{{ url_for('view_train_ticket', id=ticket.TrainRecordID) }}" class="btn btn-sm btn-info">查看</a>
                <a href="{{ url_for('edit_train_ticket', id=ticket.TrainRecordID) }}" class="btn btn-sm btn-warning">编辑</a>
                <form action="{{ url_for('delete_train_ticket', id=ticket.TrainRecordID) }}" method="POST" class="d-inline">
                    <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确定删除吗？')">删除</button>
                </form>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}